<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"  %>
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<HTML>
<HEAD>
<TITLE><bean:message bundle='webEditor'  key='webEditor.InsertFlash.Title' /></TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
body, a, table, div, span, td, th, input, select{font:9pt;font-family:  Verdana, Arial, Helvetica, sans-serif;}
body {padding:5px}
</style>

<script language="JavaScript" src="dialog.js"></script>

<script language="JavaScript">

function UploadSaved(sFileName){
	d_fromurl.value=GetHttpUrl(config.StyleUploadDir+"/"+sFileName);
	ReturnValue();
}

function ReturnValue(){
	var sFromUrl = GetLink(d_fromurl.value);

	dialogArguments.insertHTML(sFromUrl);

	window.returnValue = null;
	window.close();
}


function ok(){
	if (d_checkfromurl.checked){
		GetFileName(d_fromurl.value, "/");
		ReturnValue();
	}
}

function DisableItems(){
	d_checkfromfile.disabled=true;
	d_checkfromurl.disabled=true;
	d_fromurl.disabled=true;
	Ok.disabled=true;
}


function AbleItems(){
	d_checkfromfile.disabled=false;
	d_checkfromurl.disabled=false;
	d_fromurl.disabled=false;
	Ok.disabled=false;
}

function GetLink(url){
	var sExt;
	sExt=url.substr(url.lastIndexOf(".")+1);
	sExt=sExt.toUpperCase();
	var sPicName;
	switch(sExt){
	case "TXT":
		sPicName = "txt.gif"
		break;
	case "CHM":
	case "HLP":
		sPicName = "hlp.gif"
		break;
	case "DOC":
		sPicName = "doc.gif"
		break;
	case "PDF":
		sPicName = "pdf.gif"
		break;
	case "MDB":
		sPicName = "mdb.gif"
		break;
	case "GIF":
	case "JPG":
	case "PNG":
	case "BMP":
		sPicName = "pic.gif"
		break;
	case "ASP":
	case "JSP":
	case "JS":
	case "PHP":
	case "PHP3":
	case "ASPX":
		sPicName = "code.gif"
		break;
	case "HTM":
	case "HTML":
	case "SHTML":
		sPicName = "htm.gif"
		break;
	case "ZIP":
	case "RAR":
		sPicName = "zip.gif"
		break;
	case "EXE":
		sPicName = "exe.gif"
		break;
	case "AVI":
	case "MPG":
	case "MPEG":
	case "ASF":
		sPicName = "mp.gif"
		break;
	case "RA":
	case "RM":
		sPicName = "rm.gif"
		break;
	case "MID":
	case "WAV":
	case "MP3":
	case "MIDI":
		sPicName = "audio.gif"
		break;
	case "XLS":
		sPicName = "xls.gif"
		break;
	case "PPT":
	case "PPS":
		sPicName = "ppt.gif"
		break;
	default:
		sPicName = "unknow.gif"
		break;
	}
	return "<img border=0 src='"+GetHttpUrl("sysimage/file/"+sPicName)+"'><a href='"+url+"' target=_blank>"+d_filename.value+"</a>";

}


function GetFileName(url, opt){
	d_filename.value=url.substr(url.lastIndexOf(opt)+1);
}

function UploadImport(){
   var dEL = document.all("d_fromurl");
    var url = "<html:rewrite page='/protected/resmgr/initDirectory.do' />?CallFromTemplateDesign=true";
	var arr = showModalDialog(url,window,"dialogWidth:750px;dialogHeight:600px;help:no;scroll:yes;status:no");
	if (arr) {
		dEL.value=arr;
	}
}
</script>


<BODY bgColor=menu>

<table border=0 cellpadding=0 cellspacing=0 align=center>
<tr>
	<td>
	<fieldset>
	<legend><bean:message bundle="webEditor"  key="webEditor.InsertFile.Source" /></legend>
	<table border=0 cellpadding=0 cellspacing=0>
	<tr><td colspan=9 height=5></td></tr>
	<tr>
		<td width=7></td>
 		<td colspan=5><input type=text id="d_fromurl" style="width:220px" size=25 value="" ></td>
		<td width=5></td>
		<td width=7><input type=button value="<bean:message bundle='webEditor'  key='webEditor.InsertImage.Upload' />" onclick="UploadImport()"></td>
		<td width=5></td>
		<td width=5><input type=submit value="<bean:message bundle='webEditor'  key='webEditor.InsertImage.Import' />" onclick="UploadImport()"></td>
	</tr>
	<tr><td colspan=9 height=5></td></tr>
	</table>
	</fieldset>
	</td>
</tr>
<tr><td height=5></td></tr>
<tr><td align=right><input type=submit value="<bean:message bundle='webEditor'  key='webEditor.Confirm' />" id=Ok onclick="ok()">&nbsp;&nbsp;<input type=button value="<bean:message bundle='webEditor' key='webEditor.Cancel' />" onclick="window.close();"></td></tr>
</table>

<input type=hidden id=d_filename value="">
</body>
</html>
